package com.ptl.bp.config;

import com.ptl.bp.config.enums.UserRole;
import lombok.Data;

public class GlobalUserContext {
    private static final ThreadLocal<CurrentUser> USER_HOLDER = new ThreadLocal<>();

    public static CurrentUser getUser() {
        return USER_HOLDER.get();
    }

    public static void setUser(CurrentUser user) {
        USER_HOLDER.set(user);
    }

    public static void clear() {
        USER_HOLDER.remove();
    }

    @Data
    public static class CurrentUser {
        private Long userId;
        private UserRole role;
        private String accessToken;
    }
}